home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / AppMaker 2.0b3 / Demo AppMaker 2.0b3 / Examples / pre-built AMReminder / PowerPlant / CAMReminderApp.cp < prev    next >
Encoding:
Text File  |  1995-10-05  |  3.9 KB  |  194 lines  |  [TEXT/MMCC]

  1. // CAMReminderApp.cp -- application methods
  2. // Created 10/5/95 4:49 PM by AppMaker
  3.  
  4. #include "CAMReminderApp.h"
  5.  
  6. #include "CAMReminderDoc.h"
  7. #include "CAMReminderData.h"
  8. #include "CmdCodes.h"
  9.  
  10. #include <UDesktop.h>
  11. #include <URegistrar.h>
  12. #include <UScreenPort.h>
  13. #include <PPobClasses.h>
  14. #include <PP_Messages.h>
  15.  
  16. // ---------------------------------------------------------------------------
  17. //        • CAMReminderApp
  18. // ---------------------------------------------------------------------------
  19. //    Default constructor
  20.  
  21. CAMReminderApp::CAMReminderApp()
  22.     :LDocApplication()
  23. {
  24.     UScreenPort::Initialize();
  25.  
  26.     RegisterClasses();
  27.  
  28.     SetUpMenus();
  29.  
  30.     // initialize app's data:
  31.  
  32. }
  33.  
  34.  
  35. // ---------------------------------------------------------------------------
  36. //        • ~CAMReminderApp
  37. // ---------------------------------------------------------------------------
  38. //    Destructor
  39. //
  40.  
  41. CAMReminderApp::~CAMReminderApp()
  42. {
  43. }
  44.  
  45. // ---------------------------------------------------------------------------
  46. //        • RegisterClasses
  47. // ---------------------------------------------------------------------------
  48. //
  49.  
  50. void
  51. CAMReminderApp::RegisterClasses()
  52. {
  53.     RegisterAllPPClasses();
  54.             // replace to register only classes that we use.
  55.             // windows know what classes they use
  56.             // so call static functions in each window/dialog,
  57. }
  58.  
  59. // ---------------------------------------------------------------------------
  60. //        • SetUpMenus
  61. // ---------------------------------------------------------------------------
  62. //
  63.  
  64. void
  65. CAMReminderApp::SetUpMenus()
  66. {
  67.  
  68. }
  69.  
  70. // ---------------------------------------------------------------------------
  71. //        • StartUp
  72. // ---------------------------------------------------------------------------
  73. //    The application calls this member function automatically when the application
  74. //    is opened
  75.  
  76. void
  77. CAMReminderApp::StartUp()
  78. {
  79.     ObeyCommand(cmd_Open, nil);
  80. }
  81.  
  82. //----------
  83. LModelObject*
  84. CAMReminderApp::MakeNewDocument()
  85. {
  86.     CAMReminderDoc    *theDoc = new CAMReminderDoc(this);
  87.  
  88.     theDoc->newFile();
  89.  
  90.     return theDoc;
  91. }
  92.  
  93. //----------
  94. // called from SendAEOpenDoc in response to Open command
  95.  
  96. void
  97. CAMReminderApp::OpenDocument(
  98.     FSSpec    *inMacFSSpec)
  99. {
  100.     CAMReminderDoc    *theDoc = new CAMReminderDoc(this);
  101.  
  102.     theDoc->openFile (inMacFSSpec);
  103. }
  104.  
  105. //----------
  106. // called from LDocApplication in response to Open command
  107.  
  108. void
  109. CAMReminderApp::ChooseDocument()
  110. {
  111.     SFTypeList            typeList;
  112.     short                numTypes;
  113.     StandardFileReply    macFileReply;
  114.  
  115.     typeList[0] = kFileType;
  116.     numTypes = 1;
  117.  
  118.     UDesktop::Deactivate();
  119.     ::StandardGetFile(nil, numTypes, typeList, &macFileReply);
  120.     UDesktop::Activate();
  121.  
  122.     if (macFileReply.sfGood) {
  123.         SendAEOpenDoc(macFileReply.sfFile);
  124.     }
  125. }
  126.  
  127. //----------
  128. void
  129. CAMReminderApp::DoDeleteReminder ()
  130. {
  131. }
  132.  
  133. // ---------------------------------------------------------------------------
  134. //        • ObeyCommand
  135. // ---------------------------------------------------------------------------
  136. //    Respond to commands
  137.  
  138. Boolean
  139. CAMReminderApp::ObeyCommand(
  140.     CommandT    inCommand,
  141.     void        *ioParam)
  142. {
  143.     Boolean    cmdHandled = true;
  144.  
  145.     switch (inCommand) {
  146.  
  147.     // +++ Add cases here for the commands you handle
  148.     //        Remember to add same cases to FindCommandStatus below
  149.     //        to enable/disable the menu items for the commands
  150.  
  151.  
  152.     case cmdDeleteReminder:
  153.         DoDeleteReminder ();
  154.         break;
  155.  
  156.     default:
  157.             cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  158.         break;
  159.     }
  160.  
  161.     return cmdHandled;
  162. }
  163.  
  164.  
  165. // ---------------------------------------------------------------------------
  166. //        • FindCommandStatus
  167. // ---------------------------------------------------------------------------
  168. //    Pass back status of a (menu) command
  169.  
  170. void
  171. CAMReminderApp::FindCommandStatus(
  172.     CommandT    inCommand,
  173.     Boolean        &outEnabled,
  174.     Boolean        &outUsesMark,
  175.     Char16        &outMark,
  176.     Str255        outName)
  177. {
  178.     outUsesMark = false;
  179.  
  180.     switch (inCommand) {
  181.  
  182.     // +++ Add cases here for the commands you handle
  183.  
  184.     case cmdDeleteReminder:
  185.         outEnabled = true;
  186.         break;
  187.  
  188.     default:
  189.             LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  190.                                                 outMark, outName);
  191.         break;
  192.     }
  193. }
  194.